* Districts in sample
cap erase "$proc/mca_db"
cap erase "$proc/mca_coord"
shp2dta using "$gis/alt_geo/IND_adm2_selection.shp", database("$proc/mca_db") coordinates("$proc/mca_coord") genid(distid) genc(c) replace

cap erase "$proc/states_db"
cap erase "$proc/states_coord"
shp2dta using "$gis/IND_adm/IND_adm1", database("$proc/states_db") coordinates("$proc/states_coord") genid(stateid) genc(c) replace

use "$proc/mca_db", clear
	replace NAME_state = "Andhra Pradesh" if NAME_state == "Telangana"
	
	* merge with MCA mapping
	merge 1:1 ID_distric using "$raw/adm2_mca_mapping.dta"
	keep if _m == 3 
	drop _m 
	
	* merge with lang_control calc 
	merge m:1 state_MCA district_MCA using "$data/final_language_vars_mca.dta"
	keep if _m == 1 | _m == 3 
	drop _m 
	
spmap lang_control using "$proc/mca_coord", ///
	id(distid) clmethod(custom) clbreaks(0 0.07 0.18 0.36 0.64 1.01)  ndfcolor(gs6) fcolor(Blues2) ndocolor(none ..) ocolor(none ..) ///
	legorder(lohi) legend(label(6 "0.64-1") label(5 "0.36-0.64") label(4 "0.18-0.36") label(3 "0.07-0.18") label(2 "0 - 0.07") position(2) title("Share of non-state" "language speakers", size(vsmall))) ///
	line(data("$proc/states_coord") color(black))
	
graph export "$results/graphs/figure_C2.pdf", as(pdf) replace 


erase "$proc/mca_db.dta"
erase "$proc/mca_coord.dta"
erase "$proc/states_db.dta"
erase "$proc/states_coord.dta"
